home *** CD-ROM | disk | FTP | other *** search
/ IRIX Patches 1995 June / SGI IRIX Patches 1995 Jun.iso / 5.3_patches / patchSG0000281 / patchSG0000281.idb / usr / include / stdio.h.z / stdio.h
Encoding:
C/C++ Source or Header  |  1995-06-12  |  11.0 KB  |  337 lines

  1. #ifndef __STDIO_H__
  2. #define __STDIO_H__
  3. #ifdef __cplusplus
  4. extern "C" {
  5. #endif
  6. #ident "$Revision: 1.50 $"
  7. /*
  8. *
  9. * Copyright 1992, Silicon Graphics, Inc.
  10. * All Rights Reserved.
  11. *
  12. * This is UNPUBLISHED PROPRIETARY SOURCE CODE of Silicon Graphics, Inc.;
  13. * the contents of this file may not be disclosed to third parties, copied or
  14. * duplicated in any form, in whole or in part, without the prior written
  15. * permission of Silicon Graphics, Inc.
  16. *
  17. * RESTRICTED RIGHTS LEGEND:
  18. * Use, duplication or disclosure by the Government is subject to restrictions
  19. * as set forth in subdivision (c)(1)(ii) of the Rights in Technical Data
  20. * and Computer Software clause at DFARS 252.227-7013, and/or in similar or
  21. * successor clauses in the FAR, DOD or NASA FAR Supplement. Unpublished -
  22. * rights reserved under the Copyright Laws of the United States.
  23. */
  24. /*    Copyright (c) 1988 AT&T    */
  25. /*      All Rights Reserved      */
  26.  
  27. /*    THIS IS UNPUBLISHED PROPRIETARY SOURCE CODE OF AT&T    */
  28. /*    The copyright notice above does not evidence any       */
  29. /*    actual or intended publication of such source code.    */
  30.  
  31. /*
  32. * User-visible pieces of the ANSI C standard I/O package.
  33. */
  34.  
  35. #if defined(_LANGUAGE_C) || defined(_LANGUAGE_C_PLUS_PLUS)
  36.  
  37. #if !defined(_SIZE_T) && !defined(_SIZE_T_)
  38. #define _SIZE_T
  39. #if (_MIPS_SZLONG == 32)
  40. typedef unsigned int     size_t;
  41. #endif
  42. #if (_MIPS_SZLONG == 64)
  43. typedef unsigned long     size_t;
  44. #endif
  45. #endif 
  46.  
  47. typedef long    fpos_t;
  48. #if (defined(_SGI_SOURCE) && !defined(_POSIX_SOURCE) && !defined(_XOPEN_SOURCE) && !defined(_ABI_SOURCE))
  49. /* LINTED long long */
  50. typedef long long    fpos64_t;
  51. #endif
  52.  
  53. #endif /* defined(_LANGUAGE_C) || defined(_LANGUAGE_C_PLUS_PLUS) */
  54.  
  55. #ifndef NULL
  56. #define NULL        0
  57. #endif 
  58.  
  59.  
  60. #define BUFSIZ    4096
  61. #define _NFILE    100    /* initial number of streams */
  62. #define _SBFSIZ    8    /* compatibility with shared libs */
  63.  
  64. #if defined(_LANGUAGE_C) || defined(_LANGUAGE_C_PLUS_PLUS)
  65. #define _IOFBF        0000    /* full buffered */
  66. #define _IOLBF        0100    /* line buffered */
  67. #define _IONBF        0004    /* not buffered */
  68. #define _IOEOF        0020    /* EOF reached on read */
  69. #define _IOERR        0040    /* I/O error from system */
  70.  
  71. #define _IOREAD        0001    /* currently reading */
  72. #define _IOWRT        0002    /* currently writing */
  73. #define _IORW        0200    /* opened for reading and writing */
  74. #define _IOMYBUF    0010    /* stdio malloc()'d buffer */
  75. #endif /* defined(_LANGUAGE_C) || defined(_LANGUAGE_C_PLUS_PLUS) */
  76.  
  77. #if defined(_LANGUAGE_FORTRAN)
  78. #define _IOFBF        '0000'x    /* full buffered */
  79. #define _IOLBF        '0040'x    /* line buffered */
  80. #define _IONBF        '0004'x    /* not buffered */
  81. #define _IOEOF        '0010'x    /* EOF reached on read */
  82. #define _IOERR        '0020'x    /* I/O error from system */
  83. #define _IOREAD        '0001'x    /* currently reading */
  84. #define _IOWRT        '0002'x    /* currently writing */
  85. #define _IORW        '0080'x    /* opened for reading and writing */
  86. #define _IOMYBUF    '0008'x    /* stdio malloc()'d buffer */
  87. #endif    /* defined(_LANGUAGE_FORTRAN) */
  88.  
  89. #if defined(_LANGUAGE_C) || defined(_LANGUAGE_C_PLUS_PLUS)
  90.  
  91. #ifndef EOF
  92. #   define EOF    (-1)
  93. #endif
  94.  
  95. #define FOPEN_MAX    _NFILE
  96. #define FILENAME_MAX    1024    /* max # of characters in a path name */
  97.  
  98. #ifndef SEEK_SET
  99. #define SEEK_SET    0
  100. #define SEEK_CUR    1
  101. #define SEEK_END    2
  102. #endif     /* SEEK_SET */
  103. #define TMP_MAX        17576    /* 26 * 26 * 26 */
  104.  
  105. #if defined(_SVR4_SOURCE) || defined(_POSIX_SOURCE) || defined(_XOPEN_SOURCE)
  106. #define L_ctermid    9
  107. #define L_cuserid    9
  108. #endif
  109.  
  110. #if (defined(_SVR4_SOURCE) && !defined(_POSIX_SOURCE)) || defined(_XOPEN_SOURCE)
  111. #define P_tmpdir    "/var/tmp/"
  112. #endif
  113.  
  114. #define L_tmpnam    25    /* (sizeof(P_tmpdir) + 15) */
  115.  
  116. #define stdin    (&__iob[0])    
  117. #define stdout    (&__iob[1])    
  118. #define stderr    (&__iob[2])    
  119.  
  120. typedef struct    /* needs to be binary-compatible with old versions */
  121. #if defined(_SGI_SOURCE) && !defined(_POSIX_SOURCE) && !defined(_XOPEN_SOURCE) || defined(_LANGUAGE_C_PLUS_PLUS)
  122. /*
  123.  * The __file_s struct tag is for backwards compat ONLY - it shouldn't be
  124.  * used in any new headers. We would have liked to not use it in C++ since
  125.  * it will change the name mangling of FILE *, but since it has already
  126.  * gone out that way, we must stick to it. The safest thing is to *always*
  127.  * define it for C++ (since a function that takes a FILE * as an argument
  128.  * will have this tag in its mangled name).
  129.  */
  130. __file_s
  131. #endif
  132. {
  133. #if (_MIPS_SZLONG == 32)
  134.     int        _cnt;    /* number of available characters in buffer */
  135. #endif
  136. #if (_MIPS_SZLONG == 64)
  137.     long        _cnt;    /* number of available characters in buffer */
  138. #endif
  139.     unsigned char    *_ptr;    /* next character from/to here in buffer */
  140.     unsigned char    *_base;    /* the buffer */
  141. #if (_MIPS_SZLONG == 32)
  142.     unsigned char    _flag;    /* the state of the stream */
  143.     unsigned char    _file;    /* UNIX System file descriptor */
  144. #endif
  145. #if (_MIPS_SZLONG == 64)
  146.     unsigned int    _flag;    /* the state of the stream */
  147.     unsigned int    _file;    /* UNIX System file descriptor */
  148. #endif
  149. } FILE;
  150.  
  151. extern FILE        __iob[_NFILE];    
  152. extern FILE        *_lastbuf;
  153. extern unsigned char     *_bufendtab[];
  154. extern unsigned char     _sibuf[], _sobuf[];
  155.  
  156. extern int    remove(const char *);
  157. extern int    rename(const char *, const char *);
  158. extern FILE    *tmpfile(void);
  159. extern char    *tmpnam(char *);
  160. extern int    fclose(FILE *);
  161. extern int    fflush(FILE *);
  162. extern FILE    *fopen(const char *, const char *);
  163. extern FILE    *freopen(const char *, const char *, FILE *);
  164. extern void    setbuf(FILE *, char *);
  165. extern int    setvbuf(FILE *, char *, int, size_t);
  166. /* PRINTFLIKE2 */
  167. extern int    fprintf(FILE *, const char *, ...);
  168. /* SCANFLIKE2 */
  169. extern int    fscanf(FILE *, const char *, ...);
  170. /* PRINTFLIKE1 */
  171. extern int    printf(const char *, ...);
  172. /* SCANFLIKE1 */
  173. extern int    scanf(const char *, ...);
  174. /* PRINTFLIKE2 */
  175. extern int    sprintf(char *, const char *, ...);
  176. /* SCANFLIKE2 */
  177. extern int    sscanf(const char *, const char *, ...);
  178. extern int    vfprintf(FILE *, const char *, /* va_list */ char *);
  179. extern int    vprintf(const char *, /* va_list */ char *);
  180. extern int    vsprintf(char *, const char *, /* va_list */ char *);
  181. extern int    fgetc(FILE *);
  182. extern char    *fgets(char *, int, FILE *); 
  183. extern int    fputc(int, FILE *);
  184. extern int    fputs(const char *, FILE *);
  185. extern int    getc(FILE *);
  186. extern int    getchar(void);
  187. extern char    *gets(char *);
  188. extern int    putc(int, FILE *);
  189. extern int    putchar(int);
  190. extern int    puts(const char *);
  191. extern int    ungetc(int, FILE *);
  192. extern size_t    fread(void *, size_t, size_t, FILE *);
  193. #pragma int_to_unsigned fread
  194. extern size_t    fwrite(const void *, size_t, size_t, FILE *);
  195. #pragma int_to_unsigned fwrite
  196. extern int    fgetpos(FILE *, fpos_t *);
  197. extern int    fseek(FILE *, long, int);
  198. extern int    fsetpos(FILE *, const fpos_t *);
  199. extern long    ftell(FILE *);
  200. #if (defined(_SGI_SOURCE) && !defined(_POSIX_SOURCE) && !defined(_XOPEN_SOURCE) && !defined(_ABI_SOURCE))
  201. extern int    fgetpos64(FILE *, fpos64_t *);
  202. /* LINTED long long */
  203. extern int    fseek64(FILE *, long long, int);
  204. extern int    fsetpos64(FILE *, const fpos64_t *);
  205. /* LINTED long long */
  206. extern long long ftell64(FILE *);
  207. #endif
  208. extern void    rewind(FILE *);
  209. extern void    clearerr(FILE *);
  210. extern int    feof(FILE *);
  211. extern int    ferror(FILE *);
  212. extern void    perror(const char *);
  213.  
  214. extern int    __filbuf(FILE *);    
  215. extern int    __flsbuf(int, FILE *);    
  216.  
  217. #if defined(_SVR4_SOURCE) || defined(_POSIX_SOURCE) || defined(_XOPEN_SOURCE)
  218.     /* POSIX additions */
  219. extern FILE    *fdopen(int, const char *);
  220. extern char    *ctermid(char *);
  221. extern int    fileno(FILE *);
  222. #endif
  223.  
  224. #if (defined(_SVR4_SOURCE) || defined(_XOPEN_SOURCE)) && !defined(_POSIX_SOURCE)
  225.     /* SVR4/XOPEN? additions */
  226. extern FILE    *popen(const char *, const char *);
  227. extern int     pclose(FILE *);
  228. extern char    *cuserid(char *);
  229. extern char    *tempnam(const char *, const char *);
  230. extern int     getw(FILE *);
  231. extern int     putw(int, FILE *);
  232. extern int    system(const char *); /* ANSI/POSIX have this in stdlib.h */
  233.  
  234. #endif    /* defined(_SVR4_SOURCE) */
  235.  
  236. #if defined(_SGI_SOURCE) && !defined(_POSIX_SOURCE) && !defined(_XOPEN_SOURCE)
  237. extern char    *mktemp(char *);
  238. extern int    mkstemp(char *);
  239. extern int    setbuffer(FILE *, char *, int);
  240. extern int    setlinebuf(FILE *);
  241. #endif /* _SGI_SOURCE */
  242.  
  243. #if (defined(_SGI_SOURCE) && !defined(_POSIX_SOURCE) && !defined(_XOPEN_SOURCE)) || defined(_SGI_MP_SOURCE)
  244. extern int    __semputc(int, FILE *);
  245. extern int    __semgetc(FILE *);
  246. extern int    __us_rsthread_stdio;
  247. #endif
  248.  
  249. #if (defined(_SGI_SOURCE) && !defined(_POSIX_SOURCE) && !defined(_XOPEN_SOURCE)) || defined(_SGI_REENTRANT_FUNCTIONS)
  250. char *ctermid_r(char *);
  251. void flockfile(FILE *);
  252. int ftrylockfile(FILE *);
  253. void funlockfile(FILE *);
  254. int getc_unlocked(FILE *);
  255. int putc_unlocked(int, FILE *);
  256. int getchar_unlocked(void);
  257. int putchar_unlocked(int);
  258. #endif
  259.  
  260. #ifndef _LINT
  261.  
  262. #if (defined(_SGI_SOURCE) && !defined(_POSIX_SOURCE) && !defined(_XOPEN_SOURCE) && !defined(_ABI_SOURCE)) || defined(_SGI_MP_SOURCE)
  263. /* NOTE:
  264.  * The stdio macros have been modified so that they are by default 
  265.  * multi-thread  safe.
  266.  * For speed we have a single global that determines whether
  267.  * threading is required.
  268.  * There are 2 other versions of the macros:
  269.  *    macro_locked - always use locked version
  270.  *     macro_unlocked - use unlocked version - these should be used
  271.  *        with the flock/funlock-file functions
  272.  */
  273.  
  274. /* Default versions of the macros */
  275. #define getc(p)        getc_locked(p)
  276. #define putc(x, p)    putc_locked((x), p)
  277. #define getchar()    getc_locked(stdin)
  278. #define putchar(x)    putc_locked((x), stdout)
  279. #undef clearerr
  280. /* the following 3 are atomic and require no locking */
  281. #define feof(p)        feof_unlocked(p)
  282. #define ferror(p)    ferror_unlocked(p)
  283. #define fileno(p)    fileno_unlocked(p)
  284.  
  285. /* Explicit locked (thread-safe) versions */
  286. #define getc_locked(p)           (__us_rsthread_stdio ? __semgetc(p) : \
  287.             (--(p)->_cnt < 0 ? __filbuf(p) : (int)*(p)->_ptr++))
  288. #define putc_locked(x, p)         (__us_rsthread_stdio ? __semputc(x,p) : \
  289.             (--(p)->_cnt < 0 ? __flsbuf((x), (p)) \
  290.                       : (int)(*(p)->_ptr++ = (x))))
  291. #define getchar_locked()    getc_locked(stdin)
  292. #define putchar_locked(x)    putc_locked((x), stdout)
  293. #define clearerr_locked(p)    clearerr(p)
  294. #define feof_locked(p)        feof_unlocked(p)
  295. #define ferror_locked(p)    ferror_unlocked(p)
  296. #define fileno_locked(p)    fileno_unlocked(p)
  297.  
  298. /* Explicit unlocked (thread-unsafe) versions */
  299. #define getc_unlocked(p)    (--(p)->_cnt < 0 ? __filbuf(p) : (int)*(p)->_ptr++)
  300. #define putc_unlocked(x, p)    (--(p)->_cnt < 0 ? __flsbuf((x), (p)) \
  301.                 : (int)(*(p)->_ptr++ = (x)))
  302. #define getchar_unlocked()    getc_unlocked(stdin)
  303. #define putchar_unlocked(x)    putc_unlocked((x), stdout)
  304. #define clearerr_unlocked(p)    ((void)((p)->_flag &= ~(_IOERR | _IOEOF)))
  305. #define feof_unlocked(p)    (((int)(p)->_flag) & _IOEOF)
  306. #define ferror_unlocked(p)    (((int)(p)->_flag) & _IOERR)
  307. #define fileno_unlocked(p)    (p)->_file
  308.  
  309. #else
  310.  
  311. /*
  312.  * Std ANSI - thread-unsafe
  313.  */
  314.  
  315. #define getc(p)        (--(p)->_cnt < 0 ? __filbuf(p) : (int)*(p)->_ptr++)
  316. #define putc(x, p)    (--(p)->_cnt < 0 ? __flsbuf((x), (p)) \
  317.                 : (int)(*(p)->_ptr++ = (x)))
  318. #define getchar()    getc(stdin)
  319. #define putchar(x)    putc((x), stdout)
  320. #define clearerr(p)    ((void)((p)->_flag &= ~(_IOERR | _IOEOF)))
  321. #define feof(p)        (((int)(p)->_flag) & _IOEOF)
  322. #define ferror(p)    (((int)(p)->_flag) & _IOERR)
  323. #if defined(_SVR4_SOURCE) || defined(_POSIX_SOURCE) || defined(_XOPEN_SOURCE)
  324. #define fileno(p)    (p)->_file
  325. #endif
  326.  
  327. #endif /* _SGI_MP_SOURCE */
  328.  
  329. #endif /* !_LINT */
  330.  
  331. #endif /* defined(_LANGUAGE_C) || defined(_LANGUAGE_C_PLUS_PLUS) */
  332.  
  333. #ifdef __cplusplus
  334. }
  335. #endif
  336. #endif /* !__STDIO_H__ */
  337.